﻿@imports Library

@modelType ScheduleTask

@Code
    ViewData("Title") = "Edit"
    
    Dim typeList As ArrayList = New ArrayList()
    typeList.Add("DAILY")
    typeList.Add("MONTHLY")
End Code

<div id="page">

    <div id="page_header" style="position:relative;">
        Edit Record
    </div>

    <div id="page_body">
            
        <div class="IE_padding_hack">
	
            @Using Html.BeginForm("Edit", "ScheduleTask", New With {.id = Model.Id}, FormMethod.Post)
                    
                @<table class="basic">
                    <tr>
                        <th><label for="EndDate"> End Date  <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.EndDate)
                                <span> YYYY-MM format.Required. </span></td>
                    </tr><tr>
                        <th><label for="owner"> Owner <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Owner)</td>
                    </tr><tr>
                        <th><label for="Period"> Period <b class="red">*</b></label></th>
                        <td>@Html.DropDownListFor((Function(item) item.Period), new SelectList(typeList))</td>
                    </tr><tr>
                        <th><label for="Amount"> Amount <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Amount)</td>
                    </tr><tr>
                        <th><label for="recordtype"> Type <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.RecordType)</td>
                    </tr><tr>
                        <th><label for="remark"> Remark <b class="red">*</b></label></th>
                        <td>@Html.EditorFor(Function(model) model.Remark)</td>
                    </tr><tr>
                        <td colspan="2">
                            <input type="submit" id="submit" value="Save"> or 
                            <a href="javascript:void(0)" onclick="DeleteRecord()">Delete</a> or 
                            @Html.ActionLink("Cancel", "Index")
                        </td>
                    </tr>
                </table>
		
            End Using

        </div>
                    
    </div>
        
</div>

@section Scripts

<script type="text/javascript">

    $(function () {
        $("#banner li").removeClass("active").eq(4).addClass("active");

        $("#submit").click(function () {
            var amount = $("#Amount").val();
            if (IsNumeric(amount)) {
                $("#Amount").val(Math.round(amount));
                return true;
            } else {
                alert("amount is not a number!");
                return false;
            };
        });
    });

    function DeleteRecord() {
        if (confirm("Are you sure to delete this record?")) {
            window.location.href = '/ScheduleTask/delete?id=@Model.Id';
        }
    }
    
</script>

End Section